//
//  UpcomingDisplaySection.m
//  ViperDemo
//
//  Created by Leeesven on 17/5/17.
//  Copyright © 2017年 Leeesven. All rights reserved.
//

#import "UpcomingDisplaySection.h"

@interface UpcomingDisplaySection ()

@property (nonatomic, copy) NSString*   name;
@property (nonatomic, copy) NSString*   imageName;
@property (nonatomic, copy) NSArray*    items;

@end

@implementation UpcomingDisplaySection

+ (instancetype)upcomingDisplaySectionWithName:(NSString *)name
                                     imageName:(NSString *)imageName
                                         items:(NSArray *)items
{
    UpcomingDisplaySection *section = [[UpcomingDisplaySection alloc] init];
    
    section.name = name;
    section.imageName = imageName;
    section.items = items;
    
    return section;
}


- (BOOL)isEqualToUpcomingDisplaySection:(UpcomingDisplaySection *)section
{
    if (!section)
    {
        return NO;
    }
    
    BOOL hasEqualNames = [self.name isEqualToString:section.name];
    BOOL hasEqualImageNames = [self.imageName isEqualToString:section.imageName];
    BOOL hasEqualItems = [self.items isEqualToArray:section.items];
    
    return hasEqualNames && hasEqualImageNames && hasEqualItems;
}


- (BOOL)isEqual:(id)object
{
    if (self == object)
    {
        return YES;
    }
    
    if (![object isKindOfClass:[UpcomingDisplaySection class]])
    {
        return NO;
    }
    
    return [self isEqualToUpcomingDisplaySection:object];
}


- (NSUInteger)hash
{
    return [self.name hash] ^ [self.imageName hash] ^ [self.items hash];
}

@end
